package com.lancoo.znbkxx.teacher.adapter

import android.graphics.Color
import androidx.core.content.res.ResourcesCompat
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.widget.CircleImageView
import com.lancoo.znbkxx.teacher.widget.GlideCircleWithBorder

/**
 * @author : Admin
 * @date   : 2019/7/22 10:38
 * @desc   :
 */

@BindingAdapter("imageFromUrl")
fun bindImageFromUrl(view: CircleImageView, imgUrl: String) {
    Glide.with(view.context).load(imgUrl).apply(RequestOptions().error(
            ResourcesCompat.getDrawable(view.context.resources, R.mipmap.aibk_teacher_launcher,
                    null))
            .skipMemoryCache(true)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .transform(GlideCircleWithBorder( 0, Color.parseColor("#ccffffff"))))
            .into(view)
}